<html>
<head>
<title>Add cms_auth_permission</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link media="all" href="/cms/css/cms.min.css" type="text/css" rel="stylesheet" /> 
<link rel="stylesheet" type="text/css" href="/cms/css/tag/token-input.css" />
<script  type="text/javascript" src="/cms/js/cms.1.1.min.js"></script>
<script type="text/javascript" src="/cms/js/tag/jquery.tokeninput.js"></script> 
<script language="JavaScript" src="/cms/js/cleditor/jquery.cleditor.min.js"></script>
<script language="JavaScript" src="/cms/js/jquery.validate.js"></script>
<script language="JavaScript" src="/cms/js/autocomplete/textarea.js"></script>

</head>

<body>
{#include file="$navigation"#}
<div style="float:right;" id="login"></div>

<script>
$(document).ready(function() {	

});	
  function validate_form(form){
	  if (validator.form())  form.submit(); else alert('Some fields has error. Please check and resubmit');
  }
</script>

<H1><span id="parent_key_label"></span>Cms auth permission</H1>
<form name="form_showadd" method="post" id="form_showadd" action="{#$self_url#}" >	
<div class='tableWrapper' style="width:100%;margin:0;padding:0;">
  <div class='tableHeader' >

	<ul class="tableActions">
  <li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="Submit" value=" 儲存 " onclick="form.subaction.value='edit_after_add'; form.submit();" type="button"></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" type="submit" name="Submit" value=" 確定 "></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="dummy" value=" 取消 " size="3" onclick="javascript:window.location.href='{#$self_url#}/list'" type="button"></li>
	</ul>

  <div class='clear'></div>
  <div class='corner left'></div>
  <div class='corner right'></div>
  </div>	
<table border="0" cellspacing='0' >

<tr id="tr_type"><td><B>type</B></td>
<td id="td_type">{#$showadd_data.type#}</td></tr>
<tr id="tr_role"><td><B>role</B></td>
<td id="td_role">{#$showadd_data.role#}&nbsp;&nbsp;Role will have higher priority if set (other than No Permission)</td></tr>
<tr id="tr_cms_user"><td><B>cms_user</B></td>
<td id="td_cms_user">{#$showadd_data.cms_user#}</td></tr>
<tr id="tr_auth_group"><td><B>auth_group</B></td>
<td id="td_auth_group"><input id="field_auth_group" type="text" name="auth_group" value=""></td></tr>
<tr id="tr_action_permission"><td><B>action_permission</B></td>
<td id="td_action_permission">{#$showadd_data.action_permission#}</td></tr>

  <tr>
    <td>&nbsp;</td>
    <td>
     	
    <input type="hidden" name="action" value="add"><input name="subaction" type="hidden">
     <ul class="tableActions">
    <li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="Submit" value=" 儲存 " onclick="form.subaction.value='edit_after_add'; form.submit();" type="button"></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" type="submit" name="Submit" value=" 確定 "></li><li><input class="psbutton" onmouseover="this.className='psbuttonhover'" onmouseout="this.className='psbutton'" name="dummy" value=" 取消 " size="3" onclick="javascript:window.location.href='{#$self_url#}/list'" type="button"></li>
    </ul>
  </td>
  </tr>
</table>

</form>

<script type="text/javascript"> 	
$(function(){
  $(".tips").tipTip({defaultPosition: "right", edgeOffset: 10});
}); 
</script>

<script type="text/javascript">

function hidden_rows_by_type(type){

  var myArray = [
    ['cms_user'], // 
    [ 'role'] ,  // 
  ];

  for (var i=0; i<myArray.length; i++) {
    if (type == i + 1){
       for (var j=0; j<myArray[i].length; j++){
         $('#tr_'+myArray[i][j]).show();
       }
    } else {
       for (var j=0; j<myArray[i].length; j++){
        $('#tr_'+myArray[i][j]).hide();
       }
    }
  }
}

$(document).ready(function() {	
	var type = parseInt($('[name|="type"]').val());
	hidden_rows_by_type(type);

	$('[name|="type"]').change(function() {
		hidden_rows_by_type(parseInt($(this).val()));
	});

});

</script> 
<!--POSTRUNJS-->
</body>
</html>
